package com.swjd.controller;

import com.swjd.dao.TMemberDao;
import com.swjd.pojo.TMember;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.sql.Date;
import java.util.List;

/**
 * @author 刘涛
 * @create 2021/10/18 12:16
 */
@Controller
public class TMemberController {
    @Autowired
    private TMemberDao tMemberDao;
    @RequestMapping("/listMember")
    public String listMember(Model model) {
        List<TMember> tMembers = tMemberDao.selectList(null);
        model.addAttribute("tMembers",tMembers);
        return "listMember";
    }
    @RequestMapping("/addMember")
    public String addMember(){
        return "addMember";
    }
    @RequestMapping("/add")
    public String add(Date regtime,String membername,String address,String select2,Integer advnum,Double money,Integer forbiddennum,Integer checknum){
        TMember tMember = new TMember();
        tMember.setRegtime(regtime);
        tMember.setMembername(membername);
        tMember.setAddress(address);
        tMember.setTypename(select2);
        tMember.setAdvnum(advnum);
        tMember.setMoney(money);
        tMember.setForbiddennum(forbiddennum);
        tMember.setChecknum(checknum);
        tMemberDao.insert(tMember);
        return "redirect:/listMember";
    }
    @RequestMapping("/ReturnlistMember")
    public String listMember() {
        return "listMember";
    }
}
